# Contributor: Thomas Kienlen <kommander@laposte.net>
# Maintainer: Thomas Kienlen <kommander@laposte.net>
pkgname=spotifyd
pkgver=0.3.5
pkgrel=3
pkgdesc="Open source Spotify client running as a UNIX daemon"
url="https://github.com/Spotifyd/spotifyd"
# rust-ring
arch="all !ppc64le !riscv64 !s390x"
license="GPL-3.0-or-later"
makedepends="
	alsa-lib-dev
	cargo
	cargo-auditable
	dbus-dev
	libogg-dev
	openssl-dev>3
	pulseaudio-dev
	"
pkgusers="spotifyd"
pkggroups="spotifyd"
install="spotifyd.pre-install"
subpackages="$pkgname-openrc"

source="https://github.com/Spotifyd/spotifyd/archive/v$pkgver/spotifyd-$pkgver.tar.gz
	bump-getrandom.patch
	bump-rustc-serialize.patch

	spotifyd.initd
	spotifyd.conf
	"

prepare() {
	default_prepare

	cargo fetch --target=$CTARGET --locked
}

build() {
	cargo auditable build --release --frozen --features pulseaudio_backend,dbus_mpris,dbus_keyring,rodio_backend
}

check() {
	cargo test --locked --target-dir=target
}

package() {
	install -D -m 755 target/release/spotifyd "$pkgdir/usr/bin/spotifyd"
	install -D -m 755 "$srcdir/spotifyd.initd" "$pkgdir/etc/init.d/spotifyd"
	install -D -m 660 -o spotifyd -g spotifyd "$srcdir/spotifyd.conf" "$pkgdir/etc/spotifyd.conf"
}

sha512sums="
c457f4927b58f7ae7b27f88a841ebb0eefd6a850bf8baec06e96c7721fc185ddd553e3189578b0c1e6673f81a1489dcd4fa4cd80b90ed26b61d4da201f8f50ef  spotifyd-0.3.5.tar.gz
6d4c3585eb7ca7e86b5fa5d3f53e92f589d34355a7dcb327cb0749c13b78ce085a3c48774685f137bb7ce9f473513f1a9f4f6ff54c900da966dfd0ccab6e911c  bump-getrandom.patch
4f6c70953f5c0d74faf7306f91df683527489edc5901f51874cd35896b95b50c5df997bba26b8b52022dc7917c91bbab97a01463d99722587e46553951b87a81  bump-rustc-serialize.patch
dd4664c5818af8de3439deedfecb2a9d6bd70ab41c3db57cf659d42d4071ffe47d137fa55d94009022472d5927668978df2e6236c574bbe35596fb386ef274a2  spotifyd.initd
3b431114226af7c67838bf860d07c4f4f661808142caadc9920d4268c1c3a89d61d99c310c13b3b4568dc6c10a5c95dfcb05a52f8551884a836a17b20b3ec06c  spotifyd.conf
"
